/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
#pragma once

#include "JSCJSValue.h"
#include <wtf/text/CString.h>

namespace JSC {

enum OpcodeID : unsigned;

namespace Profiler {

class Bytecode {
public:
    Bytecode()
        : m_bytecodeIndex(std::numeric_limits<unsigned>::max())
    {
    }
    
    Bytecode(unsigned bytecodeIndex, OpcodeID opcodeID, const CString& description)
        : m_bytecodeIndex(bytecodeIndex)
        , m_opcodeID(opcodeID)
        , m_description(description)
    {
    }
    
    unsigned bytecodeIndex() const { return m_bytecodeIndex; }
    OpcodeID opcodeID() const { return m_opcodeID; }
    const CString& description() const { return m_description; }
    
    JSValue toJS(ExecState*) const;
private:
    unsigned m_bytecodeIndex;
    OpcodeID m_opcodeID;
    CString m_description;
};

inline unsigned getBytecodeIndexForBytecode(Bytecode* bytecode) { return bytecode->bytecodeIndex(); }

} } // namespace JSC::Profiler
